<?php include 'header-inc.php'; ?>

    <div id="inner-wrap">
        <div id="sidebar">
<?php include 'sidebar-inc.php'; ?>

        </div>
        <div id="content-box">
            <div class="inner-box">
                <div class="cmd">
                    <ul>
                        <li><a href="<?php echo $this->_url($_GET[FLEA::getAppInf( 'controllerAccessor' )], 'addcategory', array(array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey))); ?>">添加产品分类</a></li>
                        <li><a href="<?php echo $this->_url($_GET[FLEA::getAppInf( 'controllerAccessor' )], 'sortcategory', array(array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey))); ?>">分类排序</a></li>
                        <li><a href="<?php echo $this->_url($_GET[FLEA::getAppInf( 'controllerAccessor' )], null, array(array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey))); ?>">返回产品列表</a></li>
                    </ul>
                </div>
                <div class="pdbox catebox box">
                    <table>
                        <tr>
                            <th width="10%">编号</th>
                            <th width="40%" class="tl">分类名称</th>
                            <th width="30%">分类图片</th>
                            <th width="20%">管理</th>
                        </tr>
                        <?php if ($data['rows']): ?>
                        <?php foreach ($data['rows'] as $row): ?>
                        <?php
                        if ($row['child']) {
                            $class = 'parent-cate';
                            $links = '<a href="' . $this->_url('products', 'editcategory', array( array('cate_id' => $row['cate_id']), array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey ) )) . '">编辑分类</a> | <a href="' . $this->_url('products', 'addcategory', array( array('cate_id' => $row['cate_id']), array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey ) )) . '">添加子类</a>';
                        } elseif ($row['parent_id']==0) {
                            $class = 'nor-cate';
                            $links = '<a href="' . $this->_url('products', 'editcategory', array( array('cate_id' => $row['cate_id']), array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey ) )) . '">编辑分类</a> | <a href="#" onclick="remove('.$row['cate_id'].')">删除分类</a>';
                        }
                        ?>
                        <tr class="<?php echo $class; ?>">
                            <td><?php echo $row['cate_id']; ?></td>
                            <td class="tl"><a href="<?php echo $this->_url('products', 'editcategory', array( array('cate_id' => $row['cate_id']), array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey ) )); ?>"><?php echo $row['name']; ?></a></td>
                            <td><?php echo getImg($row['attachments'], 'thumb'); ?></td>
                            <td><?php echo $links; ?></td>
                        </tr>
                        <?php if ($row['child']): ?>
                        <?php foreach ($row['child'] as $child): ?>
                        <tr class="child-cate">
                            <td><?php echo $child['cate_id']; ?></td>
                            <td class="tl"> |- <a href="<?php echo $this->_url('products', 'editcategory', array( array('cate_id' => $child['cate_id']), array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey ) )); ?>"><?php echo $child['name']; ?></a></td>
                            <td><?php echo getImg($child['attachments'], 'thumb'); ?></td>
                            <td><a href="<?php echo $this->_url('products', 'editcategory', array( array('cate_id' => $child['cate_id']), array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey ) )); ?>">编辑分类</a> | <a href="#" onclick="remove(<?php echo $child['cate_id']; ?>)">删除分类</a></td>
                        </tr>
                        <?php endforeach; ?>
                        <?php endif; ?>
                        <?php endforeach; ?>
                        <?php endif; ?>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
<!--
    // 删除内容时显示提示信息
    function remove(id) {
        var removeUrl = '<?php echo $this->_url($_GET[FLEA::getAppInf( 'controllerAccessor' )], 'removecategory', array(array(FLEA::getAppInf( 'columnAccessor' ) => $_colkey))); ?>';
        if(confirm("您确定要删除吗?")) {
            document.location = removeUrl + '&cate_id=' + id;
            return true;
        }
        return false;
    }
//-->
</script>
</body>
</html>
